#include <iostream>
#include <queue>
#include <vector>
#include <cstring>

using namespace std;

const int N = 1e6 + 10,MOD = 100003;

int dist[N],cnt[N];
bool st[N];
int n,m;
vector<int> edges[N];

void dijkstr()
{
    memset(dist,0x3f,sizeof dist);
    cnt[1] = 1;
    dist[1] = 0;
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
    q.push({0,1});

    while(q.size())
    {
        pair<int,int> p = q.top();
        q.pop();
        int t = p.second,w=p.first;
        if(st[t] == true)continue;
        st[t] = true;
        for(auto& e : edges[t])
        {
            if(dist[t] + 1 < dist[e])
            {
                dist[e] = dist[t] + 1;
                cnt[e] = cnt[t];
                q.push({dist[e],e});
            }
            else if(dist[t]+1 == dist[e])
            {
                cnt[e] = (cnt[e] + cnt[t])%MOD;
            }
        }
    }



    for(int i = 1; i <= n; i++)
    {
       printf("%d\n",cnt[i]);
    }
}
int main()
{
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        edges[x].push_back(y);
        edges[y].push_back(x);
    }
    dijkstr();
    return 0;
}